# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=ctpl
_base_ver=0.3.3
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=0.3.3.391.6dd5c14
pkgrel=1
arch=('any')
pkgdesc="C Template (Parser) Library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "gtk-doc"
             "git")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://ctpl.tuxfamily.org/"
source=("${_realname}"::"git+https://github.com/b4n/ctpl.git")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "%s.%s.%s" "${_base_ver}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${srcdir}/${_realname}

  ./autogen.sh
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
